package com.mycode.config;

import com.mycode.service.NetbarServices;
import org.apache.cxf.Bus;
import org.apache.cxf.jaxws.EndpointImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.el.ELManager;
import javax.xml.ws.Endpoint;

@Configuration
public class CxfConfig {
    @Autowired
    private Bus bus;
    @Autowired
    private NetbarServices netbarServices;

    @Bean
    public Endpoint endpoint() {
        EndpointImpl endpoint = new EndpointImpl(bus,netbarServices);
		 //明确(暴露)该服务的接口地址，防止nginx代理时丢失端口(也可以服务器开通该端口)
        endpoint.setPublishedEndpointUrl("127.0.0.1:701/webservice/pushProperData?wsdl");
        endpoint.getInInterceptors().add(new AuthInterceptor());
        endpoint.publish("/NetbarServices");//接口发布在 /NetbarServices 目录下
        return endpoint;
    }
}